package com.example;

import javax.microedition.khronos.opengles.GL10;

import com.step.Step;
import com.step.mesh.parser.IParser;
import com.step.mesh.parser.Parser;
import com.step.scene.light.AmbientLight;
import com.step.sprite.Sprite3D;

public class Max3dParserExample extends BaseExample{
	Sprite3D sprite3d;
	AmbientLight ambientLight;
	@Override
	public void create() {
		
		IParser parser = Parser.createParser(Step.files.internal("model/monster.3ds"), true);
		parser.parse();
		sprite3d = parser.getParsedObject();
		sprite3d.setPosition(0, -1, -3);
		sprite3d.setScale(0.05f, 0.05f, 0.05f);
		
		ambientLight = new AmbientLight(1, 0, 1, 1);
	}

	float r,g,b;
	
	@Override
	public void update() {
		GL10 gl = Step.gl;
		gl.glClearColor(1, 1, 1, 1);
		gl.glEnable(GL10.GL_LIGHTING);
		ambientLight.enable(gl);
		sprite3d.draw(gl);
		sprite3d.rotate(0, 2, 0);
		r = (float)Math.random();
		g = (float)Math.random();
		b = (float)Math.random();
		ambientLight.setColor(r,g,b,1);
		gl.glDisable(GL10.GL_LIGHTING);
	}
}
